<?php
namespace App\Services\Com;
use App\Models\Common\HotSearch;

/**
 * Created by PhpStorm.
 * User: yzy
 * Date: 2019/6/26
 * Time: 19:57
 */
class CarLifeHomeService
{
    public static function accessToken(){
        try {
            $accessToken = '';

            $url = config('partner.car_life_home.'.config('partner.car_life_home.env').'.url');

            $data = [];
            $data['clientId'] = config('partner.car_life_home.'.config('partner.car_life_home.env').'.clientId');
            $data['clientSecret'] = config('partner.car_life_home.'.config('partner.car_life_home.env').'.clientSecret');
            $data['grantType'] = config('partner.car_life_home.'.config('partner.car_life_home.env').'.grantType');

            $result = UtilService::curlPost($url, $data);
            if($result['code'] != 0) throw new \Exception($result['msg']);

//            $result['data']['expiresIn'];

            $accessToken = $result['data']['accessToken'];

            return $accessToken;

        }catch (\Exception $e){
            throw new \Exception($e->getMessage());
        }
    }
}